    <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>查看珍品信息</title>

    <meta name="keywords" content="">
    <meta name="description" content="">

    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <link rel="shortcut icon" href="favicon.ico"> <link href="__STATIC__/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__STATIC__/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/css/style.css?v=4.1.0" rel="stylesheet">
    <style type="text/css">
        div{
            text-align: center;
        }
        th{
            text-align: center;
        }
        .fanye{
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="ibox-title">
        <h5>查看珍品信息</h5>
    </div>
    <form class="form-horizontal m-t" id="signupForm" action="{:url('getChoose')}" method="post" enctype="multipart/form-data">
        <div class="form-group">
            <label class="col-sm-1 control-label">茶类</label>
            <div class="col-sm-2">
                <select class="form-control m-b" name="teacase" style="font-size: 12px;">
                    <option value="10000">查看全部</option>
                    {foreach $teacase as $case}
                    <option value="{$case['id']}" {if $current}{if $case['id']==$current.id}selected='selected'{/if}{/if}>{$case['teaname']}</option>
                    {/foreach}
                    <option value="9999">其它</option>
                    }
                </select>
            </div>

            <label class="col-sm-1 control-label">产区</label>
            <div class="col-sm-2">
                <select class="form-control m-b" name="teaarea" style="font-size: 12px;">
                    <option value="10000">查看全部</option>
                    {if $current}
                    {foreach $teaarea as $t}
                    <option value="{$t.id}" {if $currentArea}{if $t.id==$currentArea.id}selected='selected'{/if}{/if}>{$t.area}</option>
                    {/foreach}
                    <option value="9999">其它</option>
                    {/if}
                </select>
            </div>
            <div class="col-sm-2">
                <button class="btn btn-primary" type="submit">提交</button>
            </div>
        </div>
    </form>

    <div class="form-horizontal m-t">
        <div class="form-group">
            <label class="col-sm-1 control-label">显示</label>
            <div class="col-sm-7">
                <label class="checkbox-inline" style="float: left;">
                    <input type="checkbox" id="inlineCheckbox6" >茶类</label>
                <label class="checkbox-inline" style="float: left;">
                    <input type="checkbox" id="inlineCheckbox7" >产地</label>
                <label class="checkbox-inline" style="float: left;">
                    <input type="checkbox" id="inlineCheckbox11" checked="">零售价格</label>
                <label class="checkbox-inline" style="float: left;">
                    <input type="checkbox" id="inlineCheckbox1" >联系方式</label>
                <label class="checkbox-inline" style="float: left;">
                    <input type="checkbox" id="inlineCheckbox4" checked>详细介绍</label>
                <label class="checkbox-inline" style="float: left;">
                    <input type="checkbox" id="inlineCheckbox8" style="display: none;"></label>
                <label class="checkbox-inline" style="float: left;">
                    <input type="checkbox" id="inlineCheckbox9" style="display: none;"></label>
                <label class="checkbox-inline" style="float: left;">
                    <input type="checkbox" id="inlineCheckbox3" style="display: none;"></label>
                {if($Think.session.user.grade==1)}
                <form action="{:url('exportExcel')}" method="post">
                    <input type="hidden" value="{$choosetea}" name="teacase">
                    <input type="hidden" value="{$choosearea}" name="teaarea">
                <button class="btn btn-primary" >导出本页</button>
                {/if}
            </form>
            </div>
        </div>
    </div>

    <div class="ibox-content">
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>排名</th>
                    <th class='case'></th>
                    <th class='area'></th>
                    <th>珍品名称</th>
                    <th style="width:82px;">分数(60~100分)</th>
                    <th>评价</th>
                    <th class='producer'>出品人</th>
                    <th class="price" style="width:42px;">零售价/500g</th>
                    <th class="zs" style="width:42px;">正山出品</th>
                    <th class="gs" style="width:42px;">古树老丛</th>
                    <th class="ct" style="width:42px;">传统工艺</th>
                    <th class="ds" style="width:42px;">大师手制</th>
                    <th class="other">其它</th>
                    <th class="contact"></th>
                    <th class="phone"></th>
                    <th class="wechat"></th>
                    <th class="detailintro">详细介绍</th>
                    <th>上榜</th>
                    <th>修改</th>
                    <th>删除</th>
                </tr>
            </thead>
            <tbody>
                {foreach $data as $onedata}
                <tr index = "{$onedata['id']}">
                    <td>{$onedata.rank}</td>
                    <!-- 茶类 -->
                    <td >
                        <!-- <input type="" name="chooseteacase" value="{$onedata['teacase']}" style="width:50px;text-align: center;border: none;display: none; "> -->

                        <select name="chooseteacase" style="display: none;">
                            {foreach $teacase as $t}
                            <option value="{$t.id}" {if $t.teaname ==$onedata['teacase']}selected="selected"{/if}>{$t.teaname}</option>
                            {/foreach}
                        </select>
                    </td >
                    <!-- 产区 -->
                    <td >
                        <!-- <input type="" name="chooseteaarea" value="{$onedata['teaarea']}" style="width:80px;text-align: center; border: none;display: none;"> -->
                        <select name="chooseteaarea" teacase_id = "{$onedata.teacase_id}" style="display: none;">
                            {foreach $onedata.areas as $a}
                                <option value="{$a.area}" {if $a.area==$onedata.teaarea}selected="selected"{/if}>{$a.area}</option>
                            {/foreach}
                        </select>
                    </td >

                    <!-- 名称 -->
                    <td>
                        <input index="" type="text" name="name" value="{$onedata['name']}" style="width: 80px;text-align: center; border: none;">
                    </td>
                    <!-- 评分 -->
                    <td>
                        <input type="text" name="score" value="{$onedata['score']}" style="width: 60px;border: none;text-align: center;">
                    </td>
                    <th>
                        {if($onedata['score']<80)}B
                        {elseif($onedata['score']<85) /}A-
                        {elseif($onedata['score']<90) /}A
                        {elseif($onedata['score']<95) /}A+
                        {elseif($onedata['score']<=100) /}A++
                        {/if}
                    </th>
                    <!-- 出品人 -->
                    <td>
                        <input type="text" name="producer" value="{$onedata['producer']}" style="width: 80px;text-align: center;border: none;">
                    </td>
                    <!-- 零售价 -->
                    <td>
                        <input type="text" name="price" value="{$onedata['price']}" style="width: 60px;border: none;text-align: center;">
                    </td>
                    <!-- 荣誉 -->
                    <td>
                        {switch name ='$onedata.zs'}
                        {case value = "√"}
                        <input type="checkbox" name="zs" id="honor" value="√" checked>
                        {/case}
                        {case value = "×"}
                        <input type="checkbox" name="zs" id="honor" value="×"">
                        {/case}
                        {/switch}
                    </td>
                    <td>
                        {switch name = '$onedata.gs'}
                        {case value = "√"}
                        <input type="checkbox" name="gs" id="honor" value='√' checked>
                        {/case}
                        {case value = "×"}
                        <input type="checkbox" name="gs" id="honor" value="×" >
                        {/case}
                        {/switch}
                    </td>
                    <td>
                        {switch name = '$onedata.ct'}
                        {case value = "√"}
                        <input type="checkbox" name="ct" id="honor" value='√' checked>
                        {/case}
                        {case value = "×"}
                        <input type="checkbox" name="ct" id="honor" value='×'>
                        {/case}
                        {/switch}

                    </td>
                    <td>
                        {switch name = '$onedata.ds'}
                        {case value = "√"}
                        <input type="checkbox" name="ds" id="honor" value='√' checked>
                        {/case}
                        {case value = "×"}
                        <input type="checkbox" name="ds" id="honor" value='×'>
                        {/case}
                        {/switch}

                    </td>
                    <td>
                        <input type="text" name="other" id="honor" value="{$onedata['other']}" style="width: 60px;border: none;text-align: center;">
                    </td>
                    <!-- 联系人 -->
                    <td>
                        <input type="text" name="contact" value="{$onedata['contact']}" style="width: 60px;border: none;text-align: center;display: none;">
                    </td>
                    <!-- 手机 -->
                    <td>
                        <input type="text" name="phone" value="{$onedata['phone']}" style="width: 80px;border: none;text-align: center;display: none;">
                    </td>
                    <!-- 微信 -->
                    <td>
                        <input type="text" name="wechat" value="{$onedata['wechat']}" style="width: 100px;border: none;text-align: center;display: none;">
                    </td>

                    <!-- 详细介绍 -->
                    <td >
                        <textarea cols="50" rows="6" name="detailintro" style="border: none;">{$onedata['detailintro']}"
                        </textarea>
                    </td>

                    {if $onedata.bangdan_id==3}
                    <td>
                        <button class="YoN" indexm="{$onedata['id']}" value="4" style="">是</button>
                    </td>
                    {else /}
                    <td>
                        <button class="YoN" indexm="{$onedata['id']}" value="3" style="color: red;">否</button>
                    </td>
                    {/if}

                    <td>
                        <button class="modify" index="{$onedata['id']}">修改</button>
                    </td>
                    {if($Think.session.user.grade==1)}
                    <td>
                        <button class="del" del="{$onedata['id']}" data-toggle="modal"  data-target="#delmod">删除</button>
                    </td>
                    {/if}
                </tr>
                {/foreach}
            </tbody>
        </table>
    </div>



    <!-- 删除提示Modal -->
    <div class="modal fade" id="delmod" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">确定要删除吗？</h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" name="id" class="delID">
                    <p>删除后将不可恢复！！！</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-default confirmDel" data-dismiss="modal" >删除</button>
                </div>
            </div>
        </div>
    </div>


<!-- 全局js -->
<script src="__STATIC__/js/jquery.min.js?v=2.1.4"></script>
<script src="__STATIC__/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__STATIC__/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="__STATIC__/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/js/plugins/layer/layer.min.js"></script>

<!-- 自定义js -->
<script src="__STATIC__/js/hAdmin.js?v=4.1.0"></script>
<script type="text/javascript" src="__STATIC__/js/index.js"></script>

<!-- 第三方插件 -->
<script src="__STATIC__/js/plugins/pace/pace.min.js"></script>

<script type="text/javascript">
    $("select[name=chooseteacase]").change(function(){
        var teacase_id = $(this).val();
        var area = $(this).parents('tr').find('select[name=chooseteaarea]');
        var url="{:url('reTeaAreaJson')}";
        $.post(url, {teacase_id:teacase_id},function(data){
            var areas = JSON.parse(data);
            var option = '';
            for(index in areas){
                var a = "<option value="+areas[index]['area']+">"+areas[index]['area']+"</option>"
                option +=a
            }
            area.html(option)
        })

    })

    $("select[name=teacase] ").change(function(){
        var val = $(this).find("option:selected").attr("value");
        if(val == 10000){
            var inner = "<option value="+10000+">查看全部</option>";
            $("select[name=teaarea]").html(inner);
            exit();
        }
        if(val == 9999){
            var a = "<option value="+9999+">其它</option>";
            $("select[name=teaarea]").html(a);
            exit();
        }

        var url="{:url('reTeaAreaJson')}";
        $.post(url, {teacase_id:val},function(data){
            var areas = JSON.parse(data);
            var option="<option value='10000'>查看全部</option>";
            for(index in areas){
                var a = "<option value="+areas[index]['id']+">"+areas[index]['area']+"</option>"
                option +=a
            }
            option += "<option value='9999'>其它</option>";
            $("select[name=teaarea]").html(option)
        })
    })

    //删除
    $(".del").click(function(){
        var id = $(this).attr("del");
        $("input.delID").val(id);
    })

    //确认删除
    $("button.confirmDel").click(function(){
        var delID = $("input.delID").val();
        var url = "{:url('delZp')}";
        var data = {id:delID};
        $.post(url, data, function(data){
            if(data==1){
                $("tr[index="+delID+"]").remove();
                alert("删除成功");
            }
        });

    })

    $("input[type=checkbox]").click(function(){
        var value = $(this).attr("value");
        if(value=="√"){
            $(this).attr("value","×");
        }else{
            $(this).attr("value","√");
        }
    })

    //修改
    $(".modify").click(function(){
        var url = "{:url('modifyZpin')}";
        var id = $(this).attr("index");
        // var teacase = $(this).parents('tr').find("input[name=chooseteacase]").val();
        // var teaarea = $(this).parents('tr').find("input[name=chooseteaarea]").val();
        var teacase = $(this).parents('tr').find("select[name=chooseteacase]").val();
        var teaarea = $(this).parents('tr').find("select[name=chooseteaarea]").val();
        var name= $(this).parents('tr').find("input[name=name]").val();
        var producer =$(this).parents('tr').find("input[name=producer]").val();
        var zs =$(this).parents('tr').find("input[name=zs]").val();
        var gs =$(this).parents('tr').find("input[name=gs]").val();
        var ct =$(this).parents('tr').find("input[name=ct]").val();
        var ds =$(this).parents('tr').find("input[name=ds]").val();
        var other =$(this).parents('tr').find("input[name=other]").val();
        var price =$(this).parents('tr').find("input[name=price]").val();
        var contact =$(this).parents('tr').find("input[name=contact]").val();
        var phone =$(this).parents('tr').find("input[name=phone]").val();
        var wechat =$(this).parents('tr').find("input[name=wechat]").val();
        var score =$(this).parents('tr').find("input[name=score]").val();
        var detailintro =$(this).parents('tr').find("textarea[name=detailintro]").val();

        var data = {
            id:id,
            teacase:teacase,
            teaarea:teaarea,
            name:name,
            producer:producer,
            zs:zs,
            gs:gs,
            ct:ct,
            ds:ds,
            other:other,
            price:price,
            contact:contact,
            phone:phone,
            wechat:wechat,
            score:score,
            detailintro:detailintro
        };

        $.post(url,data,function(data){
            if(data == 1){
                alert('修改成功');
            }else{
                alert('修改失败');
            }
        })
    })

     $('.YoN').click(function(){
        var url = "{:url('shangbang')}";
        var a = $(this).html();
        var id = $(this).attr("indexm");
        var bangdan_id = $(this).attr("value");
        var data = {
            id:id,
            bangdan_id:bangdan_id
        }
        $.post(url,data,function(data){
            if(data == 1){
                if(a=="是"){
                    $('button[indexm='+id+']').html("否");
                    $('button[indexm='+id+']').attr('value',3);
                    $('button[indexm='+id+']').attr('style',"color: red;");
                }else{
                    $('button[indexm='+id+']').html("是");
                    $('button[indexm='+id+']').attr('value',4);
                    $('button[indexm='+id+']').attr('style',"");
                }
                alert('修改成功');
            }else{
                alert('修改失败');
            }
        })
   })

    //隐藏
    $("#inlineCheckbox1").click(function(){

        $("#inlineCheckbox3").click()
        $("#inlineCheckbox8").click()
        $("#inlineCheckbox9").click()
    })


    $("#inlineCheckbox2").click(function(){
        var a = $("th[class=phone]").html();
        if(a == '电话'){
            $("th[class=phone]").html('')
        }else{
            $("th[class=phone]").html('电话')
        }
        $("input[name=phone]").toggle();

    })

    //微信
    $("#inlineCheckbox3").click(function(){
        var a = $("th[class=wechat]").html();
        if(a == ''){
            $("th[class=wechat]").html('微信')
        }else{
            $("th[class=wechat]").html('')
        }
        $("input[name=wechat]").toggle();

    })

    // 详细介绍
    $("#inlineCheckbox4").click(function(){
        var a = $("th[class=detailintro]").html();
        if(a == ''){
            $("th[class=detailintro]").html('详细')
        }else{
            $("th[class=detailintro]").html('')
        }
        $("textarea[name=detailintro]").toggle();

    })

    $("#inlineCheckbox5").click(function(){
        var a = $("th[class=detailintro]").html();
        if(a == '详情'){
            $("th[class=detailintro]").html('')
        }else{
            $("th[class=detailintro]").html('详情')
        }
        $("textarea[name=detailintro]").toggle();

    })

    $("#inlineCheckbox6").click(function(){
        var a = $("th[class=case]").html();
        if(a == ''){
            $("th[class=case]").html('茶类')
        }else{
            $("th[class=case]").html('')
        }
        $("select[name=chooseteacase]").toggle();

    })

    $("#inlineCheckbox7").click(function(){
        var a = $("th[class=area]").html();
        if(a == ''){
            $("th[class=area]").html('产地')
        }else{
            $("th[class=area]").html('')
        }
        $("select[name=chooseteaarea]").toggle();

    })

    $("#inlineCheckbox8").click(function(){
        var a = $("th[class=contact]").html();
        if(a == ''){
            $("th[class=contact]").html('联系人');
        }else{
            $("th[class=contact]").html('');
        }

        $("input[name=contact]").toggle();

    })

    $("#inlineCheckbox9").click(function(){
       var a = $("th[class=phone]").html();
        if(a == ''){
            $("th[class=phone]").html('电话');
        }else{
            $("th[class=phone]").html('');
        }

        $("input[name=phone]").toggle();

    })

    //零售价格
    $("#inlineCheckbox11").click(function(){
        var a = $("th[class=price]").html();
        if(a == ''){
            $("th[class=price]").html('零售价/500g')
        }else{
            $("th[class=price]").html('')
        }
        $("input[name=price]").toggle();

    })

</script>

</body>
</html>